package com.hongxun.design.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hongxun.design.R;
import com.hongxun.design.bean.UserPointBean;

import java.util.List;

/**
 * Created by zerdoor_pc on 2016/6/6.
 */
public class UserPointAdapter extends BaseAdapter {
    Context context;
    List<UserPointBean> listBeans;
    LayoutInflater inflater;

    public UserPointAdapter(Context context, List<UserPointBean> listBeans) {
        this.context = context;
        this.listBeans = listBeans;
        inflater = LayoutInflater.from(context);

    }


    @Override
    public int getCount() {
         return listBeans.size();
    }

    @Override
    public Object getItem(int i) {
        return listBeans.get(i);
    }

    @Override
    public long getItemId(int i) {
         return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Holldler holldler = null;
        if (view == null) {
            view = inflater.inflate(R.layout.listview_item_userpoint, null);
            holldler = new Holldler(view);
            view.setTag(holldler);
        } else {
            holldler = (Holldler) view.getTag();
        }
        UserPointBean bean;
        try {
            bean = (UserPointBean) getItem(i);
            holldler.number.setText(bean.getNumber());
            holldler.user_name.setText(bean.getUser_name());
            holldler.all_user.setText(bean.getAll_user());
            holldler.index.setText(bean.getIndex()+"");
        } catch (Exception e) {
        }
        return view;
    }

    class Holldler {
        TextView index, number, user_name, all_user;
        Holldler(View v) {
            index = (TextView) v.findViewById(R.id.userpoint_index);
            number = (TextView) v.findViewById(R.id.userpoint_number);
            user_name = (TextView) v.findViewById(R.id.userpoint_user_name);
            all_user = (TextView) v.findViewById(R.id.userpoint_all_user);
        }
    }

}
